﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="EmployeeContract.aspx.cs"
    Inherits="WebUI.Pages.EmployeeContractPage" MasterPageFile="~/MasterPage/Default.Master" %>
<%@ Register Src="../UserControls/EmployeeNavigate.ascx" TagName="EmployeeNavigate" TagPrefix="HRM" %>

<asp:Content runat="server" ContentPlaceHolderID="cphMain">
    <h3>
        Hợp đồng lao động:
        <HRM:EmployeeNavigate runat="server" ID="ucEmpNavigate" />
    </h3>
    <div style="margin: 5 0 0 15">
        <asp:LinkButton runat="server" Text="Thêm" ID="lnkAdd" Font-Size="10pt" 
           onclick="lnkAdd_Click"></asp:LinkButton>
    </div>
    
    <div style="margin: 5 0 0 15">
        <asp:GridView runat="server" ID="grvEmployeeContract" Width="80%" AutoGenerateColumns="false"
            OnRowDataBound="grvEmployeeContract_RowDataBound" OnRowCreated="grvEmployeeContract_RowCreated"
            OnRowCommand="grvEmployeeContract_RowCommand" OnPageIndexChanging="grvEmployeeContract_PageIndexChanging">
            <Columns>
                <asp:TemplateField>
                    <ItemStyle Width="16" />
                    <ItemTemplate>
                        <input type="checkbox" name="chkSelect" />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="ID" Visible="false" />
                <asp:BoundField DataField="ContractTypeID" HeaderText="Loại HĐLĐ" />
                <asp:BoundField DataField="From" HeaderText="Từ ngày" ItemStyle-HorizontalAlign="Center"
                    DataFormatString="{0:dd/MM/yyyy}" />
                <asp:BoundField DataField="To" HeaderText="Đến ngày" ItemStyle-HorizontalAlign="Center"
                    DataFormatString="{0:dd/MM/yyyy}" />
                <asp:TemplateField >
                    <ItemStyle HorizontalAlign="Center" />
                    <ItemTemplate>
                        <div style="font-size: 8pt">
                            <asp:LinkButton runat="server" ID="lnkBtnEdit" Text="Sửa" CommandArgument='<%#Eval("ID")%>'
                                CommandName="EditContract"></asp:LinkButton>
                            <asp:LinkButton runat="server" ID="lnkBtnDelete" Text="Xóa" CommandArgument='<%#Eval("ID")%>'
                                CommandName="DeleteContract"></asp:LinkButton>
                        </div>
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
            <EmptyDataTemplate>
                <div class="message">
                    Nhân viên này chưa có hợp đồng lao động nào.
                </div>
            </EmptyDataTemplate>
        </asp:GridView>
        <div style="margin: 20 0 0 0;display: none;" id="divAddEdit" runat="server" >
            <table cellpadding="2" cellspacing="2">
                <tr>
                    <td>
                        Loại hợp đồng                     </td>
                    <td>
                        <asp:DropDownList runat="server" ID="ddlContract" Width="200" />
                    </td>
                </tr>
                <tr>
                    <td>
                        Từ ngày
                    </td>
                    <td>
                        <asp:TextBox runat="server" ID="txtValidFrom" Width="200"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td>
                        Đến ngày
                    </td>
                    <td>
                        <asp:TextBox runat="server" ID="txtValidTo" Width="200"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td colspan="2" align="right">
                        <asp:Button runat="server" ID="btnAction" Text="Lưu" Width="60" CommandArgument="Add"
                            OnClick="btnAction_Click" />
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        <asp:HiddenField runat="server" ID="hdfID" />
                    </td>
                </tr>
            </table>
        </div>
    </div>

    <script language="javascript" type="text/javascript">       
        function selectAll(id)
        {
            var value=document.getElementById(id).checked;
            var chkGroup = document.getElementsByName('chkSelect');
            for(i=0;i<chkGroup.length;i++)
            {
                chkGroup[i].checked=value;
            }
        }
        
        function displayAddPanel()
        {
            var div = document.getElementById('<% =divAddEdit.ClientID%>');
            div.style.display='block';
        }
        
        $(function() 
        {
            $("#<%= txtValidFrom.ClientID%>" ).datepicker(/*{showButtonPanel: true}*/);
            $("#<%= txtValidTo.ClientID%>" ).datepicker(/*{showButtonPanel: true}*/);
        });
    </script>

</asp:Content>
